package com.bst.web.hos;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.bst.common.annotation.Log;
import com.bst.common.enums.BusinessType;
import com.bst.system.domain.HosSfxmGroup;
import com.bst.system.service.IHosSfxmGroupService;
import com.bst.common.core.controller.BaseController;
import com.bst.common.core.domain.AjaxResult;
import com.bst.common.utils.poi.ExcelUtil;
import com.bst.common.core.page.TableDataInfo;

/**
 * 收费项目快速分组Controller
 * 
 * @author ruoyi
 * @date 2023-05-19
 */
@Controller
@RequestMapping("/hos/sfxm")
public class HosSfxmGroupController extends BaseController
{
    private String prefix = "system/group";

    @Autowired
    private IHosSfxmGroupService hosSfxmGroupService;

    @GetMapping()
    public String group()
    {
        return prefix + "/group";
    }

    /**
     * 查询收费项目快速分组列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(@RequestBody HosSfxmGroup hosSfxmGroup)
    {
        List<HosSfxmGroup> list = hosSfxmGroupService.selectHosSfxmGroupList(hosSfxmGroup);
        return getDataTable(list);
    }

    /**
     * 导出收费项目快速分组列表
     */
    @Log(title = "收费项目快速分组", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(HosSfxmGroup hosSfxmGroup)
    {
        List<HosSfxmGroup> list = hosSfxmGroupService.selectHosSfxmGroupList(hosSfxmGroup);
        ExcelUtil<HosSfxmGroup> util = new ExcelUtil<HosSfxmGroup>(HosSfxmGroup.class);
        return util.exportExcel(list, "收费项目快速分组数据");
    }

    /**
     * 新增收费项目快速分组
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存收费项目快速分组
     */
    @Log(title = "收费项目快速分组", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(HosSfxmGroup hosSfxmGroup)
    {
        return toAjax(hosSfxmGroupService.insertHosSfxmGroup(hosSfxmGroup));
    }

    /**
     * 修改收费项目快速分组
     */
    @GetMapping("/edit/{idSfxmGroup}")
    public String edit(@PathVariable("idSfxmGroup") Long idSfxmGroup, ModelMap mmap)
    {
        HosSfxmGroup hosSfxmGroup = hosSfxmGroupService.selectHosSfxmGroupByIdSfxmGroup(idSfxmGroup);
        mmap.put("hosSfxmGroup", hosSfxmGroup);
        return prefix + "/edit";
    }

    /**
     * 修改保存收费项目快速分组
     */
    @Log(title = "收费项目快速分组", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(HosSfxmGroup hosSfxmGroup)
    {
        return toAjax(hosSfxmGroupService.updateHosSfxmGroup(hosSfxmGroup));
    }

    /**
     * 删除收费项目快速分组
     */
    @Log(title = "收费项目快速分组", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(hosSfxmGroupService.deleteHosSfxmGroupByIdSfxmGroups(ids));
    }

    /**
     * 修改保存收费项目快速分组
     */
    @Log(title = "收费项目快速分组", businessType = BusinessType.UPDATE)
    @PostMapping("/saveBatch")
    @ResponseBody
    public AjaxResult saveBatch(@RequestBody List<HosSfxmGroup> list)
    {
        return toAjax(hosSfxmGroupService.batchSaveSfxmGroup(list));
    }
}
